package com.bjsxt.reflex;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class GetConstructor2 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class clazz = Users.class;
        Constructor constructor=clazz.getConstructor(String.class,int.class);
        Object o = constructor.newInstance("oldlu",28);
        Users users = (Users)o;
        System.out.println(users.getAge()+users.getUsername());
    }
}
